package com.meta.pic.view

import androidx.annotation.IntDef
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.MvRxState
import com.airbnb.mvrx.Uninitialized
import com.meta.pic.PicItem

/**
 * 描述当前 ui 的状态
 * @param location 地点
 * @param request 请求信息
 * @param list 当前数据
 * @param nextPage 下一个 page, -1:没有了
 * @param layoutType 当前布局类型
 */
data class HomeState(
    val location: String = DEFAULT_LOCATION,
    val request: Async<Pair<List<PicItem>, Int>> = Uninitialized,
    val list: List<PicItem> = emptyList(),
    val nextPage: Int = 0,
    @HomeLayoutType
    val layoutType: Int = GRID
) : MvRxState {


    companion object {
        const val STAGGERED_GRID = 0
        const val GRID = 1
        const val DEFAULT_LOCATION = "北京"
    }

    @IntDef(
        STAGGERED_GRID,
        GRID
    )
    @kotlin.annotation.Retention(AnnotationRetention.SOURCE)
    annotation class HomeLayoutType
}